<template>
  <div id="app">
    <iframe id="iframe" ref="emqxIframe" :src="computedIframeSrc" frameborder="0" width="100%" height="1000"></iframe>
  </div>
</template>

<script>
import {getToken} from '@/api/cps/emqx-api';
import Qs from 'qs'


export default {
  name: 'equipment',

  data() {
    return {
      token: '',
      iframePath: ''
    };
  },

  computed: {
    computedIframeSrc() {
      return `http://192.168.1.249:18083/#/dashboard/overview`;
    }
  },
created() {

},
  mounted() {

    let iframe = document.getElementById("iframe")
    console.log(iframe.getElementsByClassName('oper-wrapper'))
    console.log(document.getElementById("iframe").document)
  },

  methods: {
    getToken() {
      getToken().then(res => {
        this.token = res.data;
      }).catch(error => {
        console.error('Failed to get token:', error);
      });
    },

    task() {
      let user = {
        username: "admin",
        password: "public"
      }
      this.$axios
        .post(`http://192.168.1.249:18083/api/v5/login`, Qs.stringify(user, { arrayFormat: 'repeat' }), {
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        })
        .then((res) => {
          console.log(res.data);
        });
    }
  }
};
</script>
